package com.ywr;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * @ClassName JsonUtil
 * @Description TODO
 * @Author dengjie
 * @Date 2020/11/26 22:30
 */
public class JsonUtil {
    private JsonUtil() {
    }

    private static Gson gson = new GsonBuilder().create();


    public static <T> T jsonToBean(String jsonStr, Class<T> tClass) {
        try {
            return gson.fromJson(jsonStr, tClass);
        } catch (Exception exe) {
            throw new SystemErrorException(exe);
        }
    }

    public static String writeToJson(Object obj) {
        return gson.toJson(obj);

    }

}
